package com.fjrz.bbxwj.entity

import com.chad.library.adapter.base.entity.MultiItemEntity
import com.fjrz.bbxwj.app.RZApplication
import com.module.lemlin.rxhttp.HttpServiceData

data class MessageInfoResponse(
    val data: MessageInfo
) : HttpServiceData()

data class MessageInfo(
    val last_announcement: LastAnnouncement?,
    val last_message: LastMessage?,
    val unread_announcements_count: Int,
    val unread_messages_count: Int
)

data class LastAnnouncement(
    val content: String,
    val createtime: Long,
    val id: Int
)

data class LastMessage(
    val content: String,
    val createtime: Long,
    val id: Int
)

data class AnnouncementResponse(
    val data: Data1Page<Announcement>
) : HttpServiceData() {
    var loadMore = false
}

data class Announcement(
    val content: String,
    val createtime: Long,
    val id: Int,
    val is_publish: Int,
    val is_read: Int,
    val user: User,
    val user_id: Int
)


data class AnnouncementDetailsResponse(
    val data: AnnouncementDetails
) : HttpServiceData()

data class AnnouncementDetails(
    val content: String,
    val createtime: Long,
    val id: Int
)

data class MessageSystemResponse(
    val data: Data1Page<MessageSystem>
) : HttpServiceData() {
    var loadMore = false
}

data class MessageSystem(
    val content: String,
    val createtime: Long,
    val id: Int,
    val is_read: Int,
    val showswitch: Int,
    val user: User,
    val user_id: Int
)


data class MessageSystemDetailsResponse(
    val data: MessageSystemDetails
) : HttpServiceData()

data class MessageSystemDetails(
    val content: String,
    val createtime: Long,
    val id: Int
)

data class MessageLikeResponse(
    val data: Data1Page<MessageLike>
) : HttpServiceData() {
    var loadMore = false
}

data class MessageCommentResponse(
    val data: Data1Page<MessageComment>
) : HttpServiceData() {
    var loadMore = false
}

data class MessageReplyResponse(
    val data: Data1Page<MessageReply>
) : HttpServiceData() {
    var loadMore = false
}

data class MessageLike(
    val createtime: Long,
    val id: Int,
    val operate_user: User,
    val operate_user_id: Int,
    val type: Int,
    val user_id: Int,
    val video: Video,
    val video_id: Int
)

data class MessageComment(
    val at_comment_id: Any,
    val at_user_id: Any,
    val base_comment_id: Any,
    val content: String,
    val createtime: Long,
    val id: Int,
    val user: User,
    val user_id: Int,
    val video: Video,
    val video_id: Int
)

data class MessageReply(
    val at_comment_id: Int,
    val at_user_id: Int,
    val base_comment_id: Int,
    val content: String,
    val createtime: Long,
    val id: Int,
    val user: User,
    val user_id: Int,
    val video: Video,
    val video_id: Int
)

data class Video(
    val id: Int,
    val main_image: String?,
    val path: String,
    val title: String
)

data class ChatIndexResponse(
    val data: MutableList<ChatIndex> = mutableListOf()
) : HttpServiceData()

data class ChatIndex(
    val chat_id: Int,
    val chat_list_id: Int,
    val latest_message: LatestMessage,
    val object_user: User,
    val object_user_id: Int,
    val unread: Int
)


data class ChatListResponse(
    val data: Data1Page<ChatList>
) : HttpServiceData()

data class ChatList(
    val content: String,
    val createtime: Int,
    val id: Int,
    val type: Int,
    val user: User,
    val user_id: Int
) : MultiItemEntity {

    companion object{
        const val SEND = 1
        const val RECEIVE = 2
    }

    override val itemType: Int
        get() = if (RZApplication.userInfoMe()?.id == user_id) 1 else 2
}

data class LatestMessage(
    val chat_id: Int,
    val content: String,
    val createtime: Long,
    val type: Int
)

data class SocketLoginRequest(
    val type: String = SocketType.LOGIN.desc,
    val user_id: String,
    val token: String
)


data class SocketSendRequest(
    val type: String = SocketType.SEND.desc,
    val content: String,
    val msg_type: String = "1",
    val object_user_id: String,
    val token: String,
    val user_id: String
)

data class SocketSendResponse(
    val content: String,
    val createtime: Int,
    val msg_type: String
) : SocketResponse()


open class SocketResponse {
    val type: String? = null
}

enum class SocketType(val desc: String) {
    LOGIN_SUCCESSFUL("login_successful"),
    SEND_SUCCESS("send_success"),
    SEND_FAILED("send_failed"),
    RECEIVE("receive"),
    LOGIN("login"),
    SEND("send")
}
